package com.qust.edu.aliyun.controller;

import com.qust.edu.aliyun.pojo.Category;
import com.qust.edu.aliyun.service.CategoryService;
import com.qust.edu.aliyun.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * projectName: aliyun_guanli
 *
 * @author: 姜龙
 * time: 2021/9/28 17:20
 * description:
 */
@RestController
@CrossOrigin("*")
@RequestMapping("category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;
    /**
     * 查询全部分类

     * @return
     */

    @PostMapping("getCategory")
    public Object getCategory( ){
        Object r=categoryService.getCategory();
        return  r;
    }

    /**
     * 添加分类
     * @param category
     * @return
     */
    @PostMapping("getAddCategory")
    public R getAddCategory(@RequestBody Category category){
        R r=categoryService.getAddCategory(category);
        System.out.println("r = ------------" + r);
        return  r;
    }

    /**
     * 删除分类，根据id
     * @param category
     * @return
     */
    @PostMapping("getDeleteCategory")
    public Object getDeleteCategory(@RequestBody Category category ){
        Object r=categoryService.getDeleteCategory(category.getCategoryId());
        return  r;
    }
}
